//
//  RecordViewController.m
//  NewChat
//
//  Created by songKX on 16/3/3.
//  Copyright © 2016年 蓝鸥. All rights reserved.
//

#import "RecordViewController.h"

#import "RecordProgress.h"

@interface RecordViewController ()

@property (nonatomic , strong)RecordProgress *pro;

@property (nonatomic , strong)NSTimer *timer;


@end

@implementation RecordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
    
    
    self.pro = [[RecordProgress alloc] initWithFrame:CGRectMake(100, 100, [UIScreen mainScreen].bounds.size.width * 0.5, [UIScreen mainScreen].bounds.size.width * 0.5)];
    
    _pro.center = CGPointMake([UIScreen mainScreen].bounds.size.width * 0.5, [UIScreen mainScreen].bounds.size.height * 0.35);
    
    
    [self.view addSubview:_pro];
    
    
    
    
    
    
    
    // Do any additional setup after loading the view.
}


//添加定时器
-(void)addTimer{
    
    
    self.timer = [NSTimer timerWithTimeInterval:0.05 target:self selector:@selector(startAction) userInfo:nil repeats:YES];
    
    [[NSRunLoop mainRunLoop] addTimer:self.timer forMode:NSRunLoopCommonModes];
    
}
//取消定时器
-(void)cancelTimer{
    
    [self.timer invalidate];
    self.timer = nil;
    
}
//定时器方法

-(void)startAction{
    
    
    self.pro.progress += 0.05;
    
    if (self.pro.progress >= 15) {
        
        
        [self cancelTimer];
    }
    
}


//开始录制
- (IBAction)recordStart:(UIButton *)sender {
    
    NSLog(@"打开定时器");
    
    
    [self addTimer];
    
    
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
